//
// Created by Administrator on 2024/6/7.
//
#include <stdio.h>
#include <string.h>
#include <math.h>

int LCS(char * x, char * y){
    int m = strlen(x), n = strlen(y);
    int dp[m + 1][n + 1];
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= m; i++) {
        char c1 = x[i-1];
        for (int j = 1; j <= n; j++) {
            char c2 = y[j - 1];
            if (c1 == c2){
                dp[i][j] = dp[i-1][j-1] + 1;
            } else {
                dp[i][j] = fmax(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    return dp[m][n];
}

int main(){

//    char c1[] = {'a', 'b', 'c', 'd', 'e'};
//    char c2[] = {'a', 'c', 'e'};
    char * c1 = {"abcde"};
    char * c2 = {"ace"};
    int length = LCS(c1, c2);
    printf("%d\n", length);

    return 0;
}